/**
 * 页面主体资源加载完成
 */
window.onload = function() {
	$("#LoadDiv").remove();
}

/**
 * 初始化
 */
$(function() {
	$("a.AIframe").unbind().click(function() {
		var url = $(this).attr("url");
		
		///
		loadUrl(url);
		return false;
	});
});

/**
 * 加载
 */
function loadIng() {
	$("#Loading").show();
}

/**
 * 加载
 */
function loadEd() {
	$("#Loading").hide();
}

/**
 * 加载
 */
function loadUrl(url) {
	loadIng(); /* 开启 */
	
	///
	$("#iframeMain").attr("src", url);
}

/**
 * 加载自适应高度页面(由iframe内页调用)
 */
function loadFix(height) {
	loadEd(); /* 关闭 */
	
	///
	if (height == undefined) {
		height = $("#iframeMain").contents().find("body").height();
	}
	
	///
	var sHeight = $(".Sidebar").height();
	if (height < sHeight) {
		height = sHeight;
	}
	if (height < 550) {
		height = 550;
	}
	$("#iframeMain").height(height+20);
}

/**
 * 提示
 */
function tipMsg(message, type) {
	if (type==undefined || type==0) {
		var className = "success";
	} else {
		var className = "failure";
	}
	
	///
	var div = $("<div>" + message.replace(/>/g, "&gt;").replace(/</g, "&lt;") + "</div>");
	div.addClass(className);
	$("#actionMsg").html(div);
	
	///
	setTimeout(function() {
		div.fadeOut();
	}, 5000);
}

/**
 * 弹出层
 */
function popUrl(url, height, title) {
	url += "?pop";
	
	///
	$.colorbox({fixed:true, iframe:true, innerWidth:870, innerHeight:height, href:url, title:title});
}

/**
 * 由弹出层进行关闭
 */
function popClose(url) {
	$.colorbox.close();
	
	///
	if (url==undefined || url=="") {
		iframeMain.refreshPage();
	} else {
		loadUrl(url);
	}
}
